from sqlalchemy import Column, Integer, String, Text, DateTime, Enum, JSON
from sqlalchemy.sql import func
from app.core.database import Base
import enum

class HistoryType(str, enum.Enum):
    PROMPT = "prompt"
    CHAT = "chat"

class History(Base):
    """历史记录模型"""
    __tablename__ = "histories"

    id = Column(Integer, primary_key=True, index=True)
    type = Column(Enum(HistoryType), nullable=False)
    input_text = Column(Text, nullable=False)
    output_text = Column(Text, nullable=False)
    parameters = Column(JSON, nullable=True)  # 存储请求参数
    created_at = Column(DateTime(timezone=True), server_default=func.now())

    class Config:
        orm_mode = True 